"""
@author: chenzhenhua
@project: jf_fashion
@file: cifar10.py
@time: 2021/8/3 0003 23:35
@desc:
"""

from tensorflow.python.keras.datasets import cifar10
from tensorflow.python.keras.utils import to_categorical


def load_cifar10():
    return cifar10.load_data()


def preprocessing(x1, y1, x2, y2):
    x_train = x1.astype('float32')
    x_test = x2.astype('float32')
    x_train /= 255
    x_test /= 255

    # Convert class vectors to binary class matrices.
    y_train = to_categorical(y1, 10)
    y_test = to_categorical(y2, 10)
    return x_train, y_train, x_test, y_test
